package org.niu.listnode;

public class DeleteK {
    public ListNode removeNthFromEnd (ListNode head, int n) {
        // write code here
        ListNode a = head;ListNode b = head;
        while(n!=0){
            n--;
            a = a.next;
        }
        while(a!=null){
            a=a.next;
            b=b.next;
        }
        return b;
    }
}
